from selenium import webdriver
from configobj import ConfigObj
import pymysql
import platform
from configs.env import current_env,env_dict
from sympy import true, false


class CommonConfig:

    def __init__(self):
        pass

    @staticmethod
    def getChromeDriver():
        driver = webdriver.Chrome()
        driver.maximize_window()
        driver.implicitly_wait(30)
        base_url = env_dict[current_env]
        driver.get(base_url)
        return driver

    @staticmethod
    def getFirefoxDriver():
        driver = webdriver.Firefox()
        driver.maximize_window()
        driver.implicitly_wait(30)
        base_url = env_dict[current_env]
        driver.get(base_url)
        return driver

    @staticmethod
    def getDbParm():
        config = ConfigObj("../configs/common_config.ini", encoding='UTF8')
        db = pymysql.connect(host=config['mysql_server']['host'], port=int(config['mysql_server']['port']), user=config['mysql_server']['user'],
                             password=config['mysql_server']['password'], database=config['mysql_server']['database'],
                             charset="UTF8")
        return db

    @staticmethod
    def isWindow(self):
        if 'Windows' == platform.system():
            return true
        else:
            return false

    @staticmethod
    def isLinux(self):
        if 'Linux' == platform.system():
            return true
        else:
            return false
